package com.tingyukeji.fastpay.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.tingyukeji.fastpay.R;
import com.tingyukeji.fastpay.base.BaseRecyclerAdapter;
import com.tingyukeji.fastpay.base.BaseViewHolder;
import com.tingyukeji.fastpay.entity.HomePageEntity;

import java.util.List;

/**
 * Created by Administrator on 2018/6/1.
 */

public class VideoAdapter extends BaseRecyclerAdapter<HomePageEntity.PanelContent> {
    private Context context;

    public VideoAdapter(List<HomePageEntity.PanelContent> mlist, Context context, boolean enable) {
        super(mlist, context, enable);
        this.context = context;
    }

    @Override
    protected int getItemLayoutId(int viewType) {
        return R.layout.item_video;
    }

    @Override
    protected void bindData(BaseViewHolder holder, final int position, final HomePageEntity.PanelContent item) {
        holder.getTextView(R.id.tv).setText(item.productName);
        holder.getTextView(R.id.tv_sub_title).setText(item.subTitle);
        Glide.with(context)
                .load(item.picUrl)
                .placeholder(R.mipmap.banner1)//图片加载出来前，显示的图片
                .error(R.mipmap.banner1)//图片加载失败后，显示的图片
                .into(holder.getImageView(R.id.iv));
    }
}
